<%@ page language="java" import="java.util.*,com.inspur.bean.User" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'EL02.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
		<%
			//对数组进行循环迭代
			String[] names={"张三","李四","王五","小六"};
			request.setAttribute("name", names);
		
		
			//迭代list集合
			List<String> list=new ArrayList<String>();
			list.add("游泳");
		    list.add("足球");
			list.add("篮球");
			request.setAttribute("list", list);
			
			
			
			
			
			//复杂类型的list集合
			List<User> list1=new ArrayList<User>();
			User user1=new User(12,"张三",22);
			User user2=new User(13,"李四",23);
			User user3=new User(14,"王五",24);
			list1.add(user1);
			list1.add(user2);
			list1.add(user3);
			request.setAttribute("list1", list1);
			
			
			//迭代map集合
			Map<String,Double> map=new HashMap<String,Double>();
			map.put("张三",8080.00);
			map.put("李四",9090.00);
			map.put("王五",10000.00);
			request.setAttribute("map",map);
			
			
		 %>
		 
		
		
		
		
		迭代数组:
		<c:forEach items="${name}" var="name1">
			${name1 }
		</c:forEach>
		<br/>
		迭代list集合:
		<c:forEach items="${list}" var="list1">
			${list1 }
		</c:forEach>

		<br/>
		迭代复杂类型的List集合：
		<table>
			<tr>
				<td>编号</td>
				<td>姓名</td>
				<td>年龄</td>
			</tr>
			
		<c:forEach items="${list1}" var="list2">
			<tr>
				<td>${list2.userNo }</td>
				<td>${list2.userName }</td>
				<td>${list2.userAge }</td>
			</tr>
		</c:forEach>
		
		</table>
		
		
			
			
		
		
		<br/>
		
		<c:forEach items="${map }" var="maps">
			${maps.key} ||
			${maps.value }
		</c:forEach>
		<br/>
  </body>
</html>
